﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TypedROBIN.Common;

namespace TypedROBIN.Imaging
{
    internal enum Level
    {
        ERROR,
        TRACE,
        INFO
    }

    internal enum LogField
    {
        LogId,
        TimeStamp,
        LogLevel,
        Message,
        TaskId,
        CallerIdentity
    }

    internal class Sorting
    {
        internal LogField LogField;
        internal SortOrder Order = SortOrder.ASC;
        internal Sorting(LogField logField, SortOrder order)
        {
            this.LogField = logField;
            this.Order = order;
        }
    }

    internal class LogData
    {
        internal string LogId;
        internal DateTime TimeStamp;
        internal Level LogLevel;
        internal string Message;
        internal string TaskId;
        internal string CallerIdentity;
        internal LogData(
            Level logLevel,
            DateTime timeStamp,
            string message,
            string taskId = null,
            string callerIdentity = null)
        {
            this.LogId = Base56.GenerateUID(10, true);
            this.LogLevel = logLevel;
            this.TimeStamp = timeStamp;
            this.Message = message;
            this.TaskId = taskId;
            this.CallerIdentity = callerIdentity;
        }
        internal LogData(
            string logId,
            Level logLevel,
            DateTime timeStamp,
            string message,
            string taskId = null,
            string callerIdentity = null)
        {
            this.LogId = logId;
            this.LogLevel = logLevel;
            this.TimeStamp = timeStamp;
            this.Message = message;
            this.TaskId = taskId;
            this.CallerIdentity = callerIdentity;
        }
        
        internal static string ORMapping(LogField logField)
        {
            switch (logField)
            {
                case LogField.LogId:
                    return "logid";
                case LogField.TimeStamp:
                    return "timestamp";
                case LogField.LogLevel:
                    return "loglevel";
                case LogField.Message:
                    return "message";
                case LogField.TaskId:
                    return "taskid";
                case LogField.CallerIdentity:
                    return "calleridentity";
                default:
                    return "logid";
            }
        }
    }
}
